package main.http;

/**
 * Created by hdt3213 on 17/3/27.
 */
public class HttpCookie {
	boolean permanent = false;
	String key;
	String value;
	String expires;
	String maxAge;

	public HttpCookie(String key, String value) {
		this.key = key;
		this.value = value;
	}

	public String build() {
		if (!permanent) {
			return  key + "=" + value;
		}
		else {
			String str = "";
			str += key + "=" + value + "; ";
			if (expires != null) {
				str += "Expires=" + expires + ";";
			}
			if (maxAge != null) {
				str += "Max-Age=" + maxAge + ";";
			}
			return str;
		}
	}

	public boolean isPermanent() {
		return permanent;
	}

	public void setPermanent(boolean permanent) {
		this.permanent = permanent;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getExpires() {
		return expires;
	}

	public void setExpires(String expires) {
		this.expires = expires;
	}

	public String getMaxAge() {
		return maxAge;
	}

	public void setMaxAge(String maxAge) {
		this.maxAge = maxAge;
	}
}
